package com.aliyun.heiyu.common.util;

import com.aliyun.heiyu.common.entity.Constant;
import com.aliyun.heiyu.common.factory.PropertiesFactory;

import java.util.Properties;


public class PropertiesUtil {

    public static Properties getProperties(String name){
        return PropertiesFactory.getProperties(name);
    }

    public static String getValue(String name, String key){
        return PropertiesFactory.getProperties(name).getProperty(key);
    }


    public static String[] getArrayValue(String name, String key){
        String value = PropertiesFactory.getProperties(name).getProperty(key);
        if(value == null || value.isEmpty()){
            return new String[0];
        }
        return value.split(Constant.SEPARATOR_COMMA);
    }

    public static String getHome(){
        return System.getProperty("user.home");
    }

    public static String getFilePath(){
        return System.getProperty("java.class.path");
    }

    public static String getPathSplit(){
        return System.getProperty("path.separator");
    }

    public static void updateProperties(String name, Properties props){
        PropertiesFactory.updateProperties1(name,props);
    }

}
